#include <54func.h>
int main(int argc,char *argv[])
{
    // ./0_server_udp 192.168.187.128 1234
    ARGS_CHECK(argc,3);
    
    int sockfd = socket(AF_INET,SOCK_DGRAM,0);
    ERROR_CHECK(sockfd,-1,"socker");

    //初始化
    struct sockaddr_in serveraddr;
    serveraddr.sin_family = AF_INET;
    serveraddr.sin_port = htons(atoi(argv[2]));
    serveraddr.sin_addr.s_addr = inet_addr(argv[1]);
    // 将socket与ip&prot绑定
    int ret = bind(sockfd,(struct sockaddr *)&serveraddr,sizeof(serveraddr));
    ERROR_CHECK(ret,-1,"bind");
    char buf[4096] = {0};
    //recvfrom：获取发送方的ip&prot，
    recvfrom(sockfd,buf,sizeof(buf),0,NULL,NULL);
    printf("client：%s\n",buf);

    return 0;
}
